"""CreateAdItemTable Migration."""

from masoniteorm.migrations import Migration


class CreateAdItemTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with create("ad_items") as table:
            table.increments("id")
            table.integer("ad_id").unsigned()
            table.foreign("ad_id").references("id").on("ads").on_delete("cascade")
            table.string("title").nullable()
            table.text("description").nullable()
            table.string("image_url")
            table.string("link_url").nullable()
            table.integer("order")
            table.enum("type", ["image", "url","page"]).default('image')
            table.enum("status", ["active", "inactive"]).default("active")
            table.datetime("create_time")
            table.datetime("update_time")
            table.timestamps()

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop("ad_items")
